/**
 * 无向连通图，删边可以获得该边的权值，
 * 每条边的权值为：两点的权值的乘积的末尾0的数量
 * 问通过删边最多能获得多少边权和，保证图连通的情况下
 * 注意到边的权值是固定的，所以首先算出所有权值
 * 然后用Kruskal算法计算MST即可，除了MST其余都删掉
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

struct _t{
    int from;
    int to;
    int w;
};

struct uf_t{

vi father;
void init(int n){father.assign(n + 1, 0);for(int i=1;i<=n;++i)father[i]=i;}
int find(int x){return x==father[x]?x:father[x]=find(father[x]);}
void unite(int x, int y){father[find(y)]=find(x);}

}UF;

int N, M;
vector<_t> Edges;
vector<pii> W;

pii f(llt x){
    pii p {0, 0};
    while(x % 2 == 0){
        x /= 2;
        ++p.first;
    } 
    while(x % 5 == 0){
        x /= 5;
        ++p.second;
    }
    return p;
}

int Total = 0;
int proc(){
    sort(Edges.begin(), Edges.end(), [](const _t & a, const _t & b){
        if(a.w != b.w) return a.w < b.w;
        if(a.from != b.from) return a.from < b.from;
        return a.to < b.to;
    });

    int left = N - 1;
    UF.init(N);
    for(const auto & e : Edges){
        if(UF.find(e.from) == UF.find(e.to)) continue;

        Total -= e.w;
        UF.unite(e.from, e.to);
        // if(0 == --left) break;
    }
    return Total;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> M;
    W.assign(N + 1, {});
    for(int i=1;i<=N;++i){
        llt a; cin >> a;
        W[i] = f(a);
    }
    Edges.assign(M, {});
    for(int a,b,i=0;i<M;++i){
        cin >> a >> b;
        Edges[i].from = a;
        Edges[i].to = b;
        Total += Edges[i].w = min(W[a].first+W[b].first, W[a].second + W[b].second);
    }
    cout << proc() << endl;
    return 0;
}